<!--
 * @Author: wangshuguang
 * @Date: 2022-03-16 18:07:55
 * @LastEditTime: 2022-03-18 17:41:37
 * @LastEditors: wangshuguang
 * @Description: 支付宝支付页面
-->
<template>
  <div />
</template>
<script>
import {
  pcAliPay
} from '@/api/sp/flow'
export default {
  mounted() {
    console.log('query', this.$route)
    pcAliPay({
      ...this.$route.query
    }).then(res => {
      console.log('res', res)
      const { businessNo, form } = res.data.data
      localStorage.setItem('zfbPayBusinessNo', businessNo)
      let div = document.querySelector('#payDiv')
      // 如果页面已经存在payDiv，则只要修改payDiv的innerHTML就可以了，否则提交的表单永远是第一个表单。
      if (!div) {
        div = document.createElement('div')
        div.id = 'payDiv'
        document.body.appendChild(div)
      }
      div.innerHTML = form
      document.querySelector('#payDiv>form').submit()
    })
  }
}
</script>

<style>

</style>
